package com.aishua.aishuawallet.fregment;

import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.aishua.aishuawallet.Constant;
import com.aishua.aishuawallet.R;
import com.aishua.aishuawallet.activity.AboutUsActivity;
import com.aishua.aishuawallet.activity.LanguageActivity;
import com.aishua.aishuawallet.activity.LoginActivity;
import com.aishua.aishuawallet.activity.MainActivity;
import com.aishua.aishuawallet.activity.RecordActivity;
import com.aishua.aishuawallet.activity.WelcomeActivity;
import com.aishua.aishuawallet.diydialog.ExitLoginDialog;
import com.aishua.aishuawallet.diydialog.TransferDialog;
import com.aishua.aishuawallet.utils.LogUtils;

import java.util.Locale;


/**
 * Created by aishua on 2018/7/31.
 */

public class FourFregment extends BaseFragment {

    private Context mContext;
    private LinearLayout ll_transaction;
    private TextView tv_exit;
    private TextView tv_slanguage;
    private TextView tv_about;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);

        mContext = getContext();
        View view = View.inflate(mContext, R.layout.fregment_four, null);

        initVeiw(view);
        return view;
    }

    private void initVeiw(View view) {

        ll_transaction = view.findViewById(R.id.ll_transaction);
        tv_exit = view.findViewById(R.id.tv_exit);
        tv_slanguage = view.findViewById(R.id.tv_slanguage);
        tv_about = view.findViewById(R.id.tv_about);
        ll_transaction.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (Constant.ISTOURIST){

                    touristMode();

                }else {

                    Intent intent = new Intent(mContext, RecordActivity.class);
                    intent.putExtra("isdispaly", false);
                    startActivity(intent);
                }


            }
        });

        tv_exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                final ExitLoginDialog exitLoginDialog = ExitLoginDialog.newInstance("确认退出登录");
                exitLoginDialog.show(getActivity().getFragmentManager(), "exit");
                exitLoginDialog.setCancelable(false);
                exitLoginDialog.setCancleButtonListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {

                        exitLoginDialog.dismiss();

                    }
                });
                exitLoginDialog.setSureButtonListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent(mContext, LoginActivity.class);
                        startActivity(intent);
                        getActivity().finish();
                    }
                });

            }
        });
        tv_slanguage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                Intent intent = new Intent(mContext, LanguageActivity.class);
                startActivity(intent);
            }
        });

        tv_about.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(mContext, AboutUsActivity.class);
                startActivity(intent);

            }
        });
    }


}
